
/**
 *  这里存放全局数据 和一些全局用到的方法
 */
export default class GameLogic {

	private static _runDevEnv: boolean = null // true 测试,false 正式

	private static _playerToken: string = "" //玩家token

	public static setPlayerToken(tStr: string) {
		this._playerToken = tStr
	}

	//获取玩家token
	public static getPlayerToken(): string {
		if (!this._playerToken) {
			this._playerToken = "server_token=s%3AO-yp4aEmZNUJcqkNw2M5BzFWmOKCmhWn.C2kFVcnNODwBaYZ3kK90B6gPwewjMIxzrYqEGSZWBPY";
		}
		return this._playerToken
	}

	//获取网络连接的地址
	public static getSocketIOUrl(): string {
		let devUrl = "https://dev-game.lovechatbar.com"
		let relUrl = "https://game.lovechatbar.com"
		if (this.getIsDebugEnv()) {
			return devUrl
		}
		return relUrl
	}

	/**
	 * 获取当前进入的是否是测试环境
	 */
	private static getIsDebugEnv() {
		if (this._runDevEnv !== null) {
			return this._runDevEnv
		}
		if (CC_DEBUG) {
			this._runDevEnv = true
			return true
		}
		if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
			// let result: boolean = native.reflection.callStaticMethod("com/cocos/game/reflectInteraction", "getIsDev", "()Z");
			// this._runDevEnv = result
			// return result
		}
		return false
	}
}
